package com.hmis.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hmis.domain.Doctor;
import com.hmis.service.DoctorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@Controller
public class DoctorDAO implements InitializingBean {


    public static DoctorService doctorService;
    public static DoctorDAO doctorDAO;
    @Autowired
    private DoctorService doctor;

    public List<Doctor> listDoctor() {
        return doctorService.list();
    }

    public Doctor findByName(String doctorName) {
        LambdaQueryWrapper<Doctor> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Doctor::getDoctorName, doctorName);
        return doctorService.getOne(queryWrapper);
    }

    public List<Doctor> listByDeptment(String deptname) {
        LambdaQueryWrapper<Doctor> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Doctor::getDeptName,deptname);
        return doctorService.list(queryWrapper);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        doctorService = doctor;
        doctorDAO = this;
    }

}
